#pragma once
#include "UIEditor_CPP.h"
#include "MainFrm.h"

class error_list
{
	static error_list m_s_instance;
	error_list(void);
public:	
	~error_list(void);

	enum error_level
	{
		lvl_information,
		lvl_warning,
		lvl_error
	};

	struct error_item{		
		wstring			m_time;
		wstring			m_project;
		wstring			m_file;
		wstring			m_desc;
		error_level		m_lvl;
	};

	typedef vector<error_item>	ErrorList;

	ErrorList	m_errors;

	static error_list& instance();

	static void log(wstring aStrProjectName, wstring aStrFileName, wstring aMsg, error_level aLvl = lvl_warning);
	static void log(wstring aStrFileName, wstring aMsg,  error_level aLvl = lvl_warning);

	void add(error_item& aItem){ 
		m_errors.push_back(aItem); 
		wstring msg;

		msg += aItem.m_time;msg+=L" | ";
		msg += aItem.m_file;msg+=L" | ";
		msg += aItem.m_desc;

		if (aItem.m_lvl == lvl_error)
		{
			g_MainFrame->GetOutputWnd()->AddString((wchar_t*)msg.c_str(), 0);
		}else
			g_MainFrame->GetOutputWnd()->AddString((wchar_t*)msg.c_str(), 1);
		
	}
	void sort();
	void clear()
	{
		m_errors.clear();
	}
};
